﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.EndModelingEntityLevel.CUiEMEndModelingEntityLevelMiniForm
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.ComponentModel;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.EndModelingEntityLevel;

internal class CUiEMEndModelingEntityLevelMiniForm : TxForm, IUiEMEndModelingForm
{
  private CApEMEndModelingEntityLevelApp m_app;
  private IContainer components;
  private Panel m_buttonsPanel;
  private Button m_buttonCancel;
  private Button m_buttonOK;
  private ToolTip m_toolTip;
  private CheckBox m_reloadWithPMICheckBox;
  private Panel m_reloadRepresentationPanel;
  private RadioButton m_radioButtonReloadInDetailedRep;
  private RadioButton m_radioButtonReloadInUnitedRep;
  private FlowLayoutPanel m_mainFlowPanel;
  private GroupBox m_representationGroupBox;
  private GroupBox m_PMIGroupBox;

  public CUiEMEndModelingEntityLevelMiniForm()
  {
    this.InitializeComponent();
    this.RegisterToUnloadDocumentEvent();
  }

  public bool EndModeling(CApEMEndModelingEntityLevelApp app)
  {
    bool flag = false;
    this.m_app = app;
    this.FillFormData();
    if (((Form) this).ShowDialog() == DialogResult.OK)
      flag = true;
    return flag;
  }

  private void FillFormData()
  {
    this.InitDefaultRepresentationLevel();
    this.InitDefaultPMILevel();
  }

  private void InitDefaultPMILevel()
  {
    this.m_reloadWithPMICheckBox.Checked = this.m_app.IsNonModelingPMILoaded;
  }

  private void InitDefaultRepresentationLevel()
  {
    this.m_radioButtonReloadInUnitedRep.Checked = this.m_app.Component.NonModelingRepresentationLevel == 4;
    this.m_radioButtonReloadInDetailedRep.Checked = !this.m_radioButtonReloadInUnitedRep.Checked;
  }

  private void m_buttonOK_Click(object sender, EventArgs e)
  {
    this.m_app.ReloadInDetailRepresentation = this.m_radioButtonReloadInDetailedRep.Checked;
    this.m_app.ReloadPMIs = this.m_reloadWithPMICheckBox.Checked;
    ((Form) this).Close();
  }

  private void m_buttonCancel_Click(object sender, EventArgs e) => ((Form) this).Close();

  private void CUiEMEndModelingEntityLevelForm_FormClosed(object sender, FormClosedEventArgs e)
  {
    this.UnRegisterFromUnloadDocumentEvent();
  }

  private void RegisterToUnloadDocumentEvent()
  {
    TxApplication.ActiveDocument.Unloading += new TxDocument_UnloadingEventHandler(this.OnUnloadDocument);
  }

  private void UnRegisterFromUnloadDocumentEvent()
  {
    TxApplication.ActiveDocument.Unloading -= new TxDocument_UnloadingEventHandler(this.OnUnloadDocument);
  }

  private void OnUnloadDocument(object sender, TxDocument_UnloadingEventArgs args)
  {
    ((Form) this).Close();
  }

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    this.components = (IContainer) new Container();
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CUiEMEndModelingEntityLevelMiniForm));
    this.m_buttonsPanel = new Panel();
    this.m_buttonCancel = new Button();
    this.m_buttonOK = new Button();
    this.m_toolTip = new ToolTip(this.components);
    this.m_reloadWithPMICheckBox = new CheckBox();
    this.m_reloadRepresentationPanel = new Panel();
    this.m_radioButtonReloadInDetailedRep = new RadioButton();
    this.m_radioButtonReloadInUnitedRep = new RadioButton();
    this.m_mainFlowPanel = new FlowLayoutPanel();
    this.m_representationGroupBox = new GroupBox();
    this.m_PMIGroupBox = new GroupBox();
    this.m_buttonsPanel.SuspendLayout();
    this.m_reloadRepresentationPanel.SuspendLayout();
    this.m_mainFlowPanel.SuspendLayout();
    this.m_representationGroupBox.SuspendLayout();
    this.m_PMIGroupBox.SuspendLayout();
    ((Control) this).SuspendLayout();
    this.m_buttonsPanel.Controls.Add((Control) this.m_buttonCancel);
    this.m_buttonsPanel.Controls.Add((Control) this.m_buttonOK);
    componentResourceManager.ApplyResources((object) this.m_buttonsPanel, "m_buttonsPanel");
    this.m_buttonsPanel.Name = "m_buttonsPanel";
    this.m_buttonCancel.DialogResult = DialogResult.Cancel;
    componentResourceManager.ApplyResources((object) this.m_buttonCancel, "m_buttonCancel");
    this.m_buttonCancel.Name = "m_buttonCancel";
    this.m_buttonCancel.UseVisualStyleBackColor = true;
    this.m_buttonCancel.Click += new EventHandler(this.m_buttonCancel_Click);
    this.m_buttonOK.DialogResult = DialogResult.OK;
    componentResourceManager.ApplyResources((object) this.m_buttonOK, "m_buttonOK");
    this.m_buttonOK.Name = "m_buttonOK";
    this.m_buttonOK.UseVisualStyleBackColor = true;
    this.m_buttonOK.Click += new EventHandler(this.m_buttonOK_Click);
    componentResourceManager.ApplyResources((object) this.m_reloadWithPMICheckBox, "m_reloadWithPMICheckBox");
    this.m_reloadWithPMICheckBox.Name = "m_reloadWithPMICheckBox";
    this.m_reloadWithPMICheckBox.UseVisualStyleBackColor = true;
    this.m_reloadRepresentationPanel.Controls.Add((Control) this.m_radioButtonReloadInDetailedRep);
    this.m_reloadRepresentationPanel.Controls.Add((Control) this.m_radioButtonReloadInUnitedRep);
    componentResourceManager.ApplyResources((object) this.m_reloadRepresentationPanel, "m_reloadRepresentationPanel");
    this.m_reloadRepresentationPanel.Name = "m_reloadRepresentationPanel";
    componentResourceManager.ApplyResources((object) this.m_radioButtonReloadInDetailedRep, "m_radioButtonReloadInDetailedRep");
    this.m_radioButtonReloadInDetailedRep.Name = "m_radioButtonReloadInDetailedRep";
    this.m_radioButtonReloadInDetailedRep.UseVisualStyleBackColor = true;
    componentResourceManager.ApplyResources((object) this.m_radioButtonReloadInUnitedRep, "m_radioButtonReloadInUnitedRep");
    this.m_radioButtonReloadInUnitedRep.Checked = true;
    this.m_radioButtonReloadInUnitedRep.Name = "m_radioButtonReloadInUnitedRep";
    this.m_radioButtonReloadInUnitedRep.TabStop = true;
    this.m_radioButtonReloadInUnitedRep.UseVisualStyleBackColor = true;
    this.m_mainFlowPanel.Controls.Add((Control) this.m_representationGroupBox);
    this.m_mainFlowPanel.Controls.Add((Control) this.m_PMIGroupBox);
    this.m_mainFlowPanel.Controls.Add((Control) this.m_buttonsPanel);
    componentResourceManager.ApplyResources((object) this.m_mainFlowPanel, "m_mainFlowPanel");
    this.m_mainFlowPanel.Name = "m_mainFlowPanel";
    this.m_representationGroupBox.Controls.Add((Control) this.m_reloadRepresentationPanel);
    componentResourceManager.ApplyResources((object) this.m_representationGroupBox, "m_representationGroupBox");
    this.m_representationGroupBox.Name = "m_representationGroupBox";
    this.m_representationGroupBox.TabStop = false;
    this.m_PMIGroupBox.Controls.Add((Control) this.m_reloadWithPMICheckBox);
    componentResourceManager.ApplyResources((object) this.m_PMIGroupBox, "m_PMIGroupBox");
    this.m_PMIGroupBox.Name = "m_PMIGroupBox";
    this.m_PMIGroupBox.TabStop = false;
    ((Form) this).AcceptButton = (IButtonControl) this.m_buttonOK;
    componentResourceManager.ApplyResources((object) this, "$this");
    ((ContainerControl) this).AutoScaleMode = AutoScaleMode.Font;
    ((Form) this).CancelButton = (IButtonControl) this.m_buttonCancel;
    ((Control) this).Controls.Add((Control) this.m_mainFlowPanel);
    ((Form) this).FormBorderStyle = FormBorderStyle.FixedDialog;
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CUiEMEndModelingEntityLevelMiniForm);
    this.SemiModal = false;
    ((Form) this).ShowIcon = false;
    ((Form) this).FormClosed += new FormClosedEventHandler(this.CUiEMEndModelingEntityLevelForm_FormClosed);
    this.m_buttonsPanel.ResumeLayout(false);
    this.m_reloadRepresentationPanel.ResumeLayout(false);
    this.m_reloadRepresentationPanel.PerformLayout();
    this.m_mainFlowPanel.ResumeLayout(false);
    this.m_representationGroupBox.ResumeLayout(false);
    this.m_PMIGroupBox.ResumeLayout(false);
    this.m_PMIGroupBox.PerformLayout();
    ((Control) this).ResumeLayout(false);
  }
}
